import axios from 'axios'
import {isServer} from '../store'

axios.defaults.timeout = 5000
axios.defaults.baseURL ='http://api.ecrun.yangsoon.cn'
// axios.defaults.withCredentials = true

//http request 拦截器
axios.interceptors.request.use(
  config => {
    // const cookie = Cookies.getJSON()
    // config.data = JSON.stringify(config.data)
    // if(cookie){
    //   config.params = {'token':token}
    // }
    config.headers = {
      'Content-Type':'application/x-www-form-urlencoded'
    }
    return config
  },
  error => {
    return Promise.reject(error)
  }
)


//http response 拦截器
axios.interceptors.response.use(
  response => {
    
    return response
  },
  error => {
    return Promise.reject(error)
  }
)
export const isDev = process.env.NODE_ENV === 'development' && !isServer ? true : false